﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class add_column_topicconfig_TopicCodg : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainOpenApiConfig_MainTopicConfig_ProjectConfigId",
                table: "MainOpenApiConfig");

            migrationBuilder.RenameColumn(
                name: "ProjectConfigId",
                table: "MainOpenApiConfig",
                newName: "TopicConfigId");

            migrationBuilder.RenameIndex(
                name: "IX_MainOpenApiConfig_ProjectConfigId",
                table: "MainOpenApiConfig",
                newName: "IX_MainOpenApiConfig_TopicConfigId");

            migrationBuilder.AddColumn<string>(
                name: "Contdesc",
                table: "MainTopicConfig",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "TopicCodg",
                table: "MainTopicConfig",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddForeignKey(
                name: "FK_MainOpenApiConfig_MainTopicConfig_TopicConfigId",
                table: "MainOpenApiConfig",
                column: "TopicConfigId",
                principalTable: "MainTopicConfig",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainOpenApiConfig_MainTopicConfig_TopicConfigId",
                table: "MainOpenApiConfig");

            migrationBuilder.DropColumn(
                name: "Contdesc",
                table: "MainTopicConfig");

            migrationBuilder.DropColumn(
                name: "TopicCodg",
                table: "MainTopicConfig");

            migrationBuilder.RenameColumn(
                name: "TopicConfigId",
                table: "MainOpenApiConfig",
                newName: "ProjectConfigId");

            migrationBuilder.RenameIndex(
                name: "IX_MainOpenApiConfig_TopicConfigId",
                table: "MainOpenApiConfig",
                newName: "IX_MainOpenApiConfig_ProjectConfigId");

            migrationBuilder.AddForeignKey(
                name: "FK_MainOpenApiConfig_MainTopicConfig_ProjectConfigId",
                table: "MainOpenApiConfig",
                column: "ProjectConfigId",
                principalTable: "MainTopicConfig",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
